package com.modai.springcloud.service.impl;

import cn.hutool.core.lang.UUID;
import com.modai.springcloud.service.IMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

/**
 * @author ：modai
 * @date ：Created in 2020-12-13 20:14
 * @description：
 */
@EnableBinding(Source.class)
@Slf4j
public class MessageService implements IMessageService {

    @Resource
    private MessageChannel output;


    @Override
    public void send() {
        String uuid = UUID.randomUUID().toString();
        boolean send = output.send(MessageBuilder.withPayload(uuid).build());
        log.info("**********生成了消息序列号： "+uuid+"\t 发送状态： "+send);
    }
}
